package com.lzhan.day17;

import java.util.Calendar;

public class DemoSingleton {
	private String value;
	private DemoSingleton(){
		
	}
	private DemoSingleton(String value){
		this.value=value;
	}
	public final DemoSingleton getInstance(String value){
		return new DemoSingleton(value);
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public static void main(String[] args) {
		DemoSingleton dd;
		try {
//			Class 对象是在加载类时由 Java 虚拟机以及通过调用类加载器中的 defineClass 方法自动构造的，
//			因此不能显式地声明一个Class对象

			dd = (DemoSingleton) Class.forName("com.lzhan.day17.DemoSingleton").newInstance();
			dd.setValue("hello");
			System.out.println(dd.getValue());
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	
	}
	
}
